﻿<catel:DataWindow x:Class="Catel.Articles._03___MVVM.Examples.NestedUserControls.HouseWindow"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:NestedUserControls="clr-namespace:Catel.Articles._03___MVVM.Examples.NestedUserControls"
                  xmlns:catel="http://catel.codeplex.com"
                  x:TypeArguments="NestedUserControls:HouseWindowViewModel"
                  SizeToContent="Manual" Width="400" Height="800">
    
    <!-- Content -->
    <Grid>
        <!-- Row definitions -->
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!-- Column definitions -->
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <!-- Name -->
        <TextBox Grid.Row="0" Text="{Binding Name}" />

        <!-- Creation date -->
        <Label Grid.Row="1" ContentStringFormat="Constructed at {0:HH:mm:ss.fff}" Content="{Binding ViewModelConstructionTime}" />

        <!-- Child objects -->
        <Button Grid.Row="2" Command="{Binding AddRoom}" Content="Add room" />
        <ScrollViewer Grid.Row="3">
            <Expander Header="Rooms" IsExpanded="False">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="20" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <ItemsControl Grid.Column="1" ItemsSource="{Binding Rooms}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <NestedUserControls:Room DataContext="{Binding}" />
                                    <Separator />
                                </StackPanel>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </Grid>
            </Expander>
        </ScrollViewer>
    </Grid>
</catel:DataWindow>
